<template>
	<view>
		<view class="row pt80 cen">
			<view class="jhhbsrrt fz28 z9 pr" :class="ikdx==idx+1?'act':''" v-for="(sd,idx) in jhhnsd" :key="idx" @tap="qihhbsd(idx)">
				<view class="f_b pr">
					{{sd}}
					<text class="xiahuaxian"></text>
				</view>
			</view>
		</view>

		<view class="pd mt100">
			<view class="gjhhbeert cen">
				<view class="kjhbjhhgserr" v-for="(sd,idx) in ctlist" @tap="qiehaunsd(idx)"  v-if="ikdx==1 &&ctlist.length>0">
					<image :src="sd.image" class="jjnnjhnbxeet cz" mode="aspectFill" ></image>
					<view class="mt20 cf fz28 ">
						{{sd.name}} - {{sd.license_full}}
					</view>
					<view class="">
						<image src="../../static/img/xuanzhong.png" class="xingbbbnxer cz" v-if="idx==xnhggsd"></image>
						<view class="hengjnbxer cz" v-else>
							
						</view>
					</view>
				</view>
				<view class="kjhbjhhgserr" v-for="(sd,idx) in ctlist" @tap="qiehaunsd(idx)"  v-if="ikdx==2 &&ctlist.length>0">
					<image :src="sd.image" class="jjnnjhnbxeet cz" mode="aspectFill" ></image>
					<view class="mt20 cf fz28 ">
						{{sd.name}} - {{sd.license_full}}
					</view>
					<view class="">
						<image src="../../static/img/xuanzhong.png" class="xingbbbnxer cz" v-if="idx==xnhggsd"></image>
						<view class="hengjnbxer cz" v-else>
							
						</view>
					</view>
				</view>
				<view class="cen z9 fz30 cen mt100" v-if="ikdx==1 &&ctlist.length<=0">
					我的车没有数据哦
				</view>
				<view class="cen z9 fz30 cen mt100" v-if="ikdx==2 &&ctlist.length<=0">
					借的车没有数据哦
				</view>
			</view>
		</view>
	
	</view>
</template>
<script>
	export default {
		data() {
			return {
				ikdx: 1,
				jhhnsd: [
					'我的车',
					'借的车'
				],
				xnhggsd:0,
				ctlist:[]

			}
		},
		components: {},
		onNavigationBarButtonTap(e) {
			uni.navigateTo({
				url:'physical'
			})
		},
		onShow(){
			this.carlist(this.ikdx)
		},
		methods: {
			qihhbsd(idx){
				this.ikdx = idx+1	
				this.carlist(this.ikdx)			
			},	
			qiehaunsd(idx){
				this.xnhggsd = idx
			},	
			async carlist(type){
				let clist=await this.get('/api/car/'+type+'/my')
				console.log("我的车",clist)
				this.ctlist=clist.data
			}
		},
		mounted() {}
	}
</script>
<style scoped>
	.gjhhbeert {
		display: grid;
		grid-template-columns: repeat(2, 1fr);
		grid-column-gap: 64upx;
	}
	.jjnnjhnbxeet{
		height: 300upx;
		width: 100%;
	}
	.xingbbbnxer{
		width: 38upx;
		height: 38upx;
	}
	.hengjnbxer{
		width: 38upx;
		height: 38upx;
		border: 1px solid #fff;
		border-radius: 50%;
		display: inline-block;
	}
</style>
